package com.javacasino.casino.config;

import com.alibaba.fastjson.JSONObject;
import com.javacasino.casino.util.CustomizedWebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.enums.ReadyState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.net.URI;

@Component
public class ThreadTaskAsync {

    Logger log = LoggerFactory.getLogger(ThreadTaskAsync.class);


    @Async(value = "myAsyncPool")
    public CustomizedWebSocketClient sendlogin(String loginInfo) {
        try {
            CustomizedWebSocketClient client = new CustomizedWebSocketClient(new URI("wss://dianzizone.com/fxCasino/fxLB?gameType=5902"), new Draft_6455());
            client.connect();
            while (!ReadyState.OPEN.equals(client.getReadyState())) {
                System.out.println("===========没连接上qqqqqqq===========");
            }
            client.send(loginInfo);
            Thread.sleep(2000);
            JSONObject json24 = new JSONObject();
            json24.put("action", "onLoadInfo2");
            client.send(String.valueOf(json24));
            return client;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
